//
//  LBWVisitorTableViewController.swift
//  weibo
//
//  Created by Limonwei on 15/12/5.
//  Copyright © 2015年 heima. All rights reserved.
//

import UIKit

class LBWVisitorTableViewController: UITableViewController {
    
    var userLogin = false
    
    //访客视图
    var visitorView: LBWVisitorView?
    
    //在这个方法里判断如果用户没有登录,就不执行super.loadView
    
    override func loadView() {
//        if userLogin {
//            super.loadView()
//        }else{
//            
//            setupVisitorView()
//            
//        }
        
        userLogin ? super.loadView() : setupVisitorView()
    }
    
    
    private func setupVisitorView(){
        
        visitorView = LBWVisitorView()
        //设置界面上的登录注册按钮点击
        visitorView?.registerButton.addTarget(self, action: "login", forControlEvents: .TouchUpInside)
        visitorView?.loginButton.addTarget(self, action: "login", forControlEvents: .TouchUpInside)
        
        view = visitorView
        
        
        view = visitorView
        
        //设置nav上面左边右边登录注册
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "login")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: "login")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    
    @objc private func login(){
        
        //弹出一个界面(登录注册)
        print("login")
    }

}














